package com.yun.algorithmproblem.huaweiod;

import java.util.HashMap;
import java.util.Scanner;

public class OD350 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] matrix = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                matrix[i][j] = sc.nextInt();
            }
        }
        maxArea(m,n,matrix);
    }

    private static void maxArea(int m, int n, int[][] matrix) {
        int maxArea=0;
        HashMap<Integer, int[]> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (map.containsKey(matrix[i][j])) {
                    int newArea=0;
                    int[] area = map.get(matrix[i][j]);
                    if (i < area[0]) {
                        area[0] = i;
                    } else if (i > area[1]) {
                        area[1] = i;
                    }
                    if (j < area[2]) {
                        area[2] = j;
                    } else if (j > area[3]) {
                        area[3] = j;
                    }
                    newArea=(area[1]-area[0]+1)*(area[3]-area[2]+1);
                    if(newArea>maxArea){
                        maxArea=newArea;
                    }
                } else {
                    if(matrix[i][j]!=0){
                        map.put(matrix[i][j], new int[]{i, i, j, j});
                    }
                }
            }
        }
        System.out.println(maxArea);
    }
}
